﻿using System;

namespace RTools_NTS.Util
{
	public class CharToken : Token
	{
		public CharToken(string s, int line) : base(line)
		{
			if (s.Length > 0)
			{
				this.obj = s[0];
			}
		}

		public CharToken(char c) : base(0)
		{
			this.obj = c;
		}

		public CharToken(char c, int line) : base(line)
		{
			this.obj = c;
		}

		public override string ToDebugString()
		{
return string.Format("CharToken: {0}", (char)this.obj);
		}

		public override string ToString()
		{
			return string.Format("{0}", (char)this.obj);
		}

		public override int GetHashCode()
		{
			return this.ToString().GetHashCode();
		}

		public override string StringValue
		{
			get
			{
				return string.Format("{0}", (char)this.obj);
			}
		}

		public override bool Equals(object other)
		{
			return other != null && base.GetType().Equals(other.GetType()) && this.obj != null && ((CharToken)other).obj != null && ((char)this.obj).Equals((char)((CharToken)other).Object);
		}
	}
}
